using System.Windows.Forms;
using CastleSample.Entity;

namespace CastleSample.Modules.Order
{
    public partial class FormViewOrder : Form
    {
        private OrderEntity m_OrderToView;

        public OrderEntity OrderToView
        {
            get { return m_OrderToView; }
            set
            {
                m_OrderToView = value;
                RefreshData();
            }
        }

        public FormViewOrder()
        {
            InitializeComponent();
        }

        public void RefreshData()
        {
            if (m_OrderToView == null)
            {
                return;
            }
            Text = string.Format("View Order {0}", m_OrderToView.OrderId);
            labelOrderId.Text = m_OrderToView.OrderId.ToString();
            dataGridViewOrderItem.DataSource = m_OrderToView.OrderItems;
        }
    }
}